package jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class JDBCDemo10 {
    public static void main(String[] args) {
        try(Connection connection = DBUtil.getConnection();){
            connection.setAutoCommit(false);
            String sql = "DElETE FROM user WHERE id=?";
            PreparedStatement ps = connection.prepareStatement(sql);
            ps.setInt(1,4);
            int count = ps.executeUpdate();
            System.out.println(count>0? "删除成功":"删除失败");
            connection.commit();
        }catch(SQLException e){
            e.printStackTrace();
        }
    }
}
